<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!doctype html>
<html>
	<head>
		<base href="<%=basePath%>" />
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="renderer" content="webkit">
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<meta name="apple-mobile-web-app-title" content="Amaze UI" />
		<link rel="stylesheet" href="layui/css/layui.css" media="all"> <!-- 适应所有设备 -->
		<style type="text/css">
		</style>
	</head>
	<% String nowDay = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); %>
	<body>
	    <br/>
	    <form class="layui-form">
	      <div class="layui-form-item">
	      <label class="layui-form-label">资源类型</label>
	      <div class="layui-input-inline">
			<select name="ResourceType" id="ResourceType" lay-filter="ResourceType">
			    <option value="1">玩家携带资源</option>
			    <option value="2">玩家金库</option>
			</select>
		  </div>
          <label class="layui-form-label">物品名称</label>
            <div class="layui-input-inline">
			<select name="ItemName" id="ItemName" lay-filter="ItemName">
			    <option value="青铜弹头">青铜弹头</option>
			    <option value="白银弹头">白银弹头</option>
			    <option value="黄金弹头">黄金弹头</option>
			    <option value="紫金弹头">紫金弹头</option>
			    <option value="锤子碎片">锤子碎片</option>
			    <option value="防水木料">防水木料</option>
			    <option value="精炼矿石">精炼矿石</option>
			    <option value="海妖外壳">海妖外壳</option>
			    <option value="潮汐精粹">潮汐精粹</option>
			    <option value="深海魔晶">深海魔晶</option>
			    <option value="倍击道具">倍击道具</option>
			    <option value="狂暴卡">狂暴卡</option>
			    <option value="分身卡">分身卡</option>
			    <option value="锁定">锁定</option>
			    <option value="冰冻">冰冻</option>
			    <option value="召唤">召唤</option>
			    <option value="金币">金币</option>
			    <option value="钻石">钻石</option>
			    <option value="积分">积分</option>
			    <option value="奖券">奖券</option>
			</select>
		  </div>
	      </div>
	      
	      <div class="layui-form-item">
	        <label class="layui-form-label">输入ID</label>
	        <div class="layui-input-inline">
	          <input type="text" name="username" id="username" required="" lay-verify="required" placeholder="输入玩家ID" class="layui-input" autocomplete="off">
	        </div>
	      </div>
	      <div class="layui-form-item">
	        <label class="layui-form-label">输入数量</label>
	        <div class="layui-input-inline">
	          <input type="number" name="Count" id="Count" style="color:red" required="" lay-verify="required"  class="layui-input">
	        </div>
	      </div>
	      <div class="layui-form-item">
            <div class="layui-input-block">
              <button class="layui-btn" lay-submit lay-filter="updateCount">立即提交</button>
              <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
	  </form>
	
	
	    <script src="js/jquery.min.js"></script>
		<script src="layui/layui.js"></script>
		<script>
		    layui.use(['layer','form'],function(){
		    	var layer = layui.layer,
		    	    form  = layui.form;
		    	form.on('submit(updateCount)',function(data){
	    			var field = data.field;
	    			$.ajax({
	    				type:'POST',
	    				url:'player/UpdatePlayerResource',
	    				async:true,
	    				data:{ResourceType:data.field.ResourceType,
	    					  ItemName:data.field.ItemName,
	    					  Count:data.field.Count,
	    					  username:data.field.username},
	    				success:function(resp){
	    					if(resp == "success"){
	    						layer.msg("操作成功",{icon:1});
	    						setTimeout(function(){
	    						    //执行操作
	    						    $("#Count").val("");
	    						    $("#username").val("");
	    						},2000);
	    					}else{
	    						layer.msg(resp,{icon:2});
	    						setTimeout(function(){
	    							var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
		                            parent.layer.close(index); //再执行关闭 
	    						},2000);
	    					}
	    				}
	    			});
		    		return false;
		    	});
		    });
		</script>
    </body>
</html>